﻿using System;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace IDEAMS.common.converter
{
    public class BoolToImageSourceConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool mode = (bool)value;
            string param = parameter.ToString();
            try
            {
                string[] paths = param.Split(':');
                if (paths.Length != 2) return null;
                if (mode)
                {
                    return new BitmapImage(new Uri("pack://application:,,,/IDEAMS;component/" + paths[0]));
                }
                else
                {
                    return new BitmapImage(new Uri("pack://application:,,,/IDEAMS;component/" + paths[1]));
                }
            }
            catch (Exception)
            {
                return null;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            return null;
        }
    }
}
